import random
import pygame

class Particle:
    def __init__(self, x, y, angle):
        self.x = x
        self.y = y
        self.size = random.randint(2, 5)
        self.color = (random.randint(100, 255), random.randint(100, 255), random.randint(100, 255))
        self.lifetime = random.randint(20, 40)
        self.angle = angle
        self.speed = random.uniform(4, 8)  # 喷出速度加倍

    def update(self):
        self.x += self.speed * pygame.math.Vector2(1, 0).rotate(self.angle).x
        self.y += self.speed * pygame.math.Vector2(1, 0).rotate(self.angle).y
        self.lifetime -= 1

    def draw(self, screen):
        pygame.draw.circle(screen, self.color, (int(self.x), int(self.y)), self.size)